package com.mq.rabbitmq.conf;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class ConnectUtils {

    public  Connection getConnect() throws IOException, TimeoutException {
        ConnectionFactory factory = new ConnectionFactory();
        factory.setUsername("zhangsan");
        factory.setPassword("123456");
        factory.setHost("服务器的IP");
        factory.setPort(5672);
       return factory.newConnection();
    }

    public static void main(String[] args) throws IOException, TimeoutException {
        ConnectUtils utils = new ConnectUtils();
        Connection connect = utils.getConnect();
        System.out.println(connect);
    }
}
